Author: dblevins
Date: Fri Feb 26 22:09:38 2010
New Revision: 916836
URL: http://svn.apache.org/viewvc?rev=916836&view=rev
Log:
javadoc and reformatting
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/AsynchronousRunner.java
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/AsynchronousRunner.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/AsynchronousRunner.java?rev=916836&r1=916835&r2=916836&view=diff
==============================================================================
---
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/AsynchronousRunner.java
(original)
+++
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/AsynchronousRunner.java
Fri Feb 26 22:09:38 2010
@@ -28,47 +28,10 @@
/**
* Utility class used to invoke methods asynchronously, using a given
{...@link Executor}.
- * For debugging purposes, a system property named
openejb.asynchronousRunner.sleepTime
- * may be set to a long value, indicating a time the execution will wait
before actually
- * running the method
- * @author Apache Software Foundation
*/
public class AsynchronousRunner {
- /**
- * A {...@link Callable} implementation which just delegates the execution
using
- * {...@link Method#invoke(Object, Object...)}
- * @author luis
- */
- private class MethodInvoker implements Callable<Object> {
- private Object object;
- private Method method;
- private Object[] arguments;
-
- public MethodInvoker(Object object, Method method, Object[] arguments)
{
- this.object = object;
- this.method = method;
- this.arguments = arguments;
- }
-
- public Object call() throws Exception {
- return method.invoke(object, arguments);
- }
- }
-
- public static void main(String[] args) throws Exception {
- Collection<String> object = new ArrayList<String>();
- Method method = object.getClass().getMethod("add", Object.class);
- Object[] arguments = {"Item 1"};
-
- AsynchronousRunner asyncRunner = new
AsynchronousRunner(Executors.newCachedThreadPool());
- Future<Object> future = asyncRunner.runAsync(object, method,
arguments);
- future.cancel(true);
- Object result = future.get(5001, TimeUnit.MILLISECONDS);
- System.out.println(result);
- }
-
- private Executor executor;
+ private final Executor executor;
public AsynchronousRunner(Executor executor) {
this.executor = executor;
@@ -88,4 +51,24 @@
return futureTask;
}
+ /**
+ * A {...@link Callable} implementation which just delegates the execution
using
+ * {...@link Method#invoke(Object, Object[])}
+ * @author luis
+ */
+ private class MethodInvoker implements Callable<Object> {
+ private Object object;
+ private Method method;
+ private Object[] arguments;
+
+ public MethodInvoker(Object object, Method method, Object[] arguments)
{
+ this.object = object;
+ this.method = method;
+ this.arguments = arguments;
+ }
+
+ public Object call() throws Exception {
+ return method.invoke(object, arguments);
+ }
+ }
}