You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by bo...@apache.org on 2007/02/09 00:55:55 UTC
svn commit: r505089 - in /incubator/ode/trunk:
bpel-api/src/main/java/org/apache/ode/bpel/iapi/
bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/
bpel-scheduler-quartz/src/main/java/org/apache/ode/bpel/scheduler/quartz/
bpel-test/src/main/java/or...
Author: boisvert
Date: Thu Feb 8 15:55:54 2007
New Revision: 505089
URL: http://svn.apache.org/viewvc?view=rev&rev=505089
Log:
Change Scheduler.execIsolatedTransaction() to return a Future<T> instead of <T> to allow asynchronous execution
Modified:
incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/Scheduler.java
incubator/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java
incubator/ode/trunk/bpel-scheduler-quartz/src/main/java/org/apache/ode/bpel/scheduler/quartz/QuartzSchedulerImpl.java
incubator/ode/trunk/bpel-test/src/main/java/org/apache/ode/test/scheduler/TestScheduler.java
Modified: incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/Scheduler.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/Scheduler.java?view=diff&rev=505089&r1=505088&r2=505089
==============================================================================
--- incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/Scheduler.java (original)
+++ incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/Scheduler.java Thu Feb 8 15:55:54 2007
@@ -24,6 +24,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
/**
* The BPEL scheduler.
@@ -31,7 +32,7 @@
public interface Scheduler {
void setJobProcessor(JobProcessor processor) throws ContextException;
-
+
/**
* Schedule a persisted job. Persisted jobs MUST survive system failure.
* They also must not be scheduled unless the transaction associated with
@@ -85,7 +86,7 @@
* @throws Exception
* @throws ContextException
*/
- <T> T execIsolatedTransaction(final Callable<T> transaction)
+ <T> Future<T> execIsolatedTransaction(final Callable<T> transaction)
throws Exception, ContextException;
/**
@@ -114,7 +115,7 @@
void beforeCompletion();
}
-
+
/**
* Interface implemented by the object responsible for job execution.
* @author mszefler
@@ -122,9 +123,9 @@
public interface JobProcessor {
void onScheduledJob(JobInfo jobInfo) throws JobProcessorException;
}
-
+
/**
- * Wrapper containing information about a scheduled job.
+ * Wrapper containing information about a scheduled job.
* @author mszefler
*/
public static class JobInfo implements Serializable {
@@ -132,19 +133,19 @@
public final String jobName;
public final int retryCount;
public final Map<String,Object> jobDetail;
-
+
public JobInfo(String jobName, Map<String,Object>jobDetail, int retryCount) {
this.jobName = jobName;
this.jobDetail = jobDetail;
this.retryCount = retryCount;
}
-
+
public String toString() {
// Wrap in hashmap in case the underlying object has no toString method.
return jobName + "["+retryCount +"]: " + new HashMap<Object, Object>(jobDetail);
- }
+ }
}
-
+
/**
* Exception thrown by the {@link JobProcessor} to indicate failure in job
* processing.
@@ -152,17 +153,17 @@
*/
public class JobProcessorException extends Exception {
private static final long serialVersionUID = 1L;
- public final boolean retry;
-
+ public final boolean retry;
+
public JobProcessorException(boolean retry) {
this.retry = retry;
}
-
+
public JobProcessorException(Throwable cause, boolean retry) {
super(cause);
this.retry = retry;
}
}
-
-
+
+
}
Modified: incubator/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java?view=diff&rev=505089&r1=505088&r2=505089
==============================================================================
--- incubator/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java (original)
+++ incubator/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java Thu Feb 8 15:55:54 2007
@@ -148,8 +148,8 @@
} catch (Exception ex) {
System.err.println(ex.getMessage());
}
-
-
+
+
}
protected TransactionManager createTransactionManager() throws Exception {
@@ -211,7 +211,7 @@
protected EndpointReferenceContext createEndpointReferenceContext() {
_eprContext = new EndpointReferenceContext() {
- public EndpointReference resolveEndpointReference(Element element) {
+ public EndpointReference resolveEndpointReference(Element element) {
String service = DOMUtils.getChildCharacterData(element);
return (EndpointReference)_endpoints.get(service);
}
@@ -262,13 +262,13 @@
return new PartnerRoleChannel() {
public EndpointReference getInitialEndpointReference() { return epr; }
public void close() { };
- };
+ };
}
};
return _bindContext;
}
-
+
private class SchedulerWrapper implements Scheduler {
QuartzSchedulerImpl _quartz;
@@ -289,21 +289,21 @@
_nextSchedule = when == null ? System.currentTimeMillis() : when.getTime();
return jobId;
}
-
+
public String scheduleVolatileJob(boolean transacted, Map<String,Object> jobDetail, Date when) throws ContextException {
String jobId = _quartz.scheduleVolatileJob(transacted, jobDetail, when);
_nextSchedule = when == null ? System.currentTimeMillis() : when.getTime();
return jobId;
}
-
+
public void cancelJob(String jobId) throws ContextException {
_quartz.cancelJob(jobId);
}
-
+
public <T> T execTransaction(Callable<T> transaction) throws Exception, ContextException {
return _quartz.execTransaction(transaction);
}
- public <T> T execIsolatedTransaction(Callable<T> transaction) throws Exception, ContextException {
+ public <T> Future<T> execIsolatedTransaction(Callable<T> transaction) throws Exception, ContextException {
return _quartz.execIsolatedTransaction(transaction);
}
@@ -317,7 +317,7 @@
public void setJobProcessor(JobProcessor processor) throws ContextException {
_quartz.setJobProcessor(processor);
-
+
}
}
Modified: incubator/ode/trunk/bpel-scheduler-quartz/src/main/java/org/apache/ode/bpel/scheduler/quartz/QuartzSchedulerImpl.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-scheduler-quartz/src/main/java/org/apache/ode/bpel/scheduler/quartz/QuartzSchedulerImpl.java?view=diff&rev=505089&r1=505088&r2=505089
==============================================================================
--- incubator/ode/trunk/bpel-scheduler-quartz/src/main/java/org/apache/ode/bpel/scheduler/quartz/QuartzSchedulerImpl.java (original)
+++ incubator/ode/trunk/bpel-scheduler-quartz/src/main/java/org/apache/ode/bpel/scheduler/quartz/QuartzSchedulerImpl.java Thu Feb 8 15:55:54 2007
@@ -51,9 +51,9 @@
/**
* Quartz-based scheduler.
- *
+ *
* @author Maciej Szefler - m s z e f l e r @ g m a i l . c o m
- *
+ *
*/
public class QuartzSchedulerImpl implements Scheduler {
@@ -264,13 +264,12 @@
}
}
- public <T> T execIsolatedTransaction(final Callable<T> transaction) throws Exception, ContextException {
- Future<T> res = _executorSvc.submit(new Callable<T>() {
+ public <T> Future<T> execIsolatedTransaction(final Callable<T> transaction) throws Exception, ContextException {
+ return _executorSvc.submit(new Callable<T>() {
public T call() throws Exception {
return execTransaction(transaction);
}
});
- return res.get();
}
protected void rollback() throws Exception {
Modified: incubator/ode/trunk/bpel-test/src/main/java/org/apache/ode/test/scheduler/TestScheduler.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-test/src/main/java/org/apache/ode/test/scheduler/TestScheduler.java?view=diff&rev=505089&r1=505088&r2=505089
==============================================================================
--- incubator/ode/trunk/bpel-test/src/main/java/org/apache/ode/test/scheduler/TestScheduler.java (original)
+++ incubator/ode/trunk/bpel-test/src/main/java/org/apache/ode/test/scheduler/TestScheduler.java Thu Feb 8 15:55:54 2007
@@ -27,6 +27,8 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
+import java.util.concurrent.FutureTask;
public class TestScheduler implements Scheduler {
ThreadLocal<List<Scheduler.Synchronizer>> _synchros = new ThreadLocal<List<Scheduler.Synchronizer>>() {
@@ -49,24 +51,24 @@
}
- public <T> T execTransaction(Callable<T> arg0) throws Exception, ContextException {
+ public <T> T execTransaction(Callable<T> transaction) throws Exception, ContextException {
begin();
try {
- T retval = arg0.call();
+ T retval = transaction.call();
return retval;
} finally {
commit();
}
}
- public <T> T execIsolatedTransaction(Callable<T> arg0) throws Exception, ContextException {
- begin();
- try {
- T retval = arg0.call();
- return retval;
- } finally {
- commit();
- }
+ public <T> Future<T> execIsolatedTransaction(final Callable<T> transaction) throws Exception, ContextException {
+ FutureTask future = new FutureTask(new Callable<T>() {
+ public T call() throws Exception {
+ return execTransaction(transaction);
+ }
+ });
+ future.run();
+ return future;
}
public void start() {