Author: gbrown
Date: Thu May 20 13:24:52 2010
New Revision: 946622

URL: http://svn.apache.org/viewvc?rev=946622&view=rev
Log:
Update drag/drop tutorial to use signed JARs (latest JRE security updates 
appear to have disabled untrusted access to native drag/drop); apply workaround 
for apparent issue with Executors.newCachedThreadPool() when running as an 
applet (IllegalThreadStateExceptions are thrown periodically and seemingly 
unpredictably).

Modified:
    pivot/trunk/core/src/org/apache/pivot/util/concurrent/Task.java
    pivot/trunk/tutorials/www/drag-and-drop.xml

Modified: pivot/trunk/core/src/org/apache/pivot/util/concurrent/Task.java
URL: 
http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/util/concurrent/Task.java?rev=946622&r1=946621&r2=946622&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/util/concurrent/Task.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/util/concurrent/Task.java Thu May 20 
13:24:52 2010
@@ -16,8 +16,9 @@
  */
 package org.apache.pivot.util.concurrent;
 
+import java.util.concurrent.AbstractExecutorService;
 import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
 
 /**
  * Abstract base class for "tasks". A task is an asynchronous operation that
@@ -64,6 +65,42 @@ public abstract class Task<V> {
         }
     }
 
+    private static class DefaultExecutorService extends 
AbstractExecutorService {
+        private boolean shutdown = false;
+
+        @Override
+        public boolean awaitTermination(long timeout, TimeUnit unit) throws 
InterruptedException {
+            return true;
+        }
+
+        @Override
+        public void shutdown() {
+            shutdownNow();
+        }
+
+        @Override
+        public java.util.List<Runnable> shutdownNow() {
+            shutdown = true;
+            return new java.util.ArrayList<Runnable>();
+        }
+
+        @Override
+        public boolean isShutdown() {
+            return shutdown;
+        }
+
+        @Override
+        public boolean isTerminated() {
+            return isShutdown();
+        }
+
+        @Override
+        public void execute(Runnable command) {
+            Thread thread = new Thread(command);
+            thread.start();
+        }
+    }
+
     private ExecutorService executorService;
 
     private V result = null;
@@ -73,11 +110,9 @@ public abstract class Task<V> {
     protected volatile long timeout = Long.MAX_VALUE;
     protected volatile boolean abort = false;
 
-    public static final ExecutorService DEFAULT_EXECUTOR_SERVICE;
-
-    static {
-        DEFAULT_EXECUTOR_SERVICE = Executors.newCachedThreadPool();
-    }
+    // TODO This is a workaround for an issue with 
Executors.newCachedThreadPool(), which
+    // unpredictably throws IllegalThreadStateException when run in an applet.
+    public static final ExecutorService DEFAULT_EXECUTOR_SERVICE = new 
DefaultExecutorService();
 
     public Task() {
         this(DEFAULT_EXECUTOR_SERVICE);

Modified: pivot/trunk/tutorials/www/drag-and-drop.xml
URL: 
http://svn.apache.org/viewvc/pivot/trunk/tutorials/www/drag-and-drop.xml?rev=946622&r1=946621&r2=946622&view=diff
==============================================================================
--- pivot/trunk/tutorials/www/drag-and-drop.xml (original)
+++ pivot/trunk/tutorials/www/drag-and-drop.xml Thu May 20 13:24:52 2010
@@ -31,7 +31,9 @@ limitations under the License.
         <p>
             Like the clipboard, drag and drop is a common metaphor for data 
transfer. By clicking
             and dragging with the mouse, the user can move, copy, or link data 
within or between
-            applications.
+            applications. It is signed to allow drag/drop integration with 
other applications; as
+            with the clipboard, untrusted applications can only perform local 
drag and drop
+            operations.
         </p>
 
         <p>
@@ -45,7 +47,7 @@ limitations under the License.
                 <td rowspan="2">
                     <application class="org.apache.pivot.wtk.ScriptApplication"
                         width="420" height="240">
-                        <libraries>
+                        <libraries signed="true">
                             <library>core</library>
                             <library>wtk</library>
                             <library>wtk-terra</library>


Reply via email to