jdk/src/share/classes/sun/awt/shell/ShellFolder.java
changeset 2489 5052722686e2
parent 715 f16baef3a20e
child 2817 f171f2417978
--- a/jdk/src/share/classes/sun/awt/shell/ShellFolder.java	Thu Feb 26 11:44:43 2009 +0300
+++ b/jdk/src/share/classes/sun/awt/shell/ShellFolder.java	Thu Mar 12 14:00:26 2009 +0300
@@ -31,6 +31,7 @@
 import java.io.*;
 import java.io.FileNotFoundException;
 import java.util.*;
+import java.util.concurrent.Callable;
 
 /**
  * @author Michael Martak
@@ -461,6 +462,35 @@
         return null;
     }
 
+    private static Invoker invoker;
+
+    /**
+     * Provides the single access point to the {@link Invoker}. It is guaranteed that the value
+     * returned by this method will be always the same.
+     *
+     * @return the singleton instance of {@link Invoker}
+     */
+    public static Invoker getInvoker() {
+        if (invoker == null) {
+            invoker = shellFolderManager.createInvoker();
+        }
+        return invoker;
+    }
+
+    /**
+     * Interface allowing to invoke tasks in different environments on different platforms.
+     */
+    public static interface Invoker {
+        /**
+         * Invokes a callable task. If the {@code task} throws a checked exception,
+         * it will be wrapped into a {@link RuntimeException}
+         *
+         * @param task a task to invoke
+         * @return the result of {@code task}'s invokation
+         */
+        <T> T invoke(Callable<T> task);
+    }
+
     /**
      * Provides a default comparator for the default column set
      */