< prev index next >

modules/javafx.graphics/src/main/java/com/sun/javafx/application/HostServicesDelegate.java

Print this page
rev 10897 : 8199357: Remove references to applets and Java Web Start from FX
Reviewed-by:


  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.javafx.application;
  27 
  28 import java.awt.Desktop;
  29 import java.io.File;
  30 import java.lang.reflect.Method;
  31 import java.net.URI;
  32 import java.security.AccessController;
  33 import java.security.PrivilegedActionException;
  34 import java.security.PrivilegedExceptionAction;
  35 import javafx.application.Application;
  36 
  37 public abstract class HostServicesDelegate {
  38 
  39     private static Method getInstanceMeth = null;
  40 
  41     public static HostServicesDelegate getInstance(final Application app) {
  42         // Call into the deploy code to get the delegate class
  43         HostServicesDelegate instance = null;
  44         try {
  45             instance = AccessController.doPrivileged(
  46                     (PrivilegedExceptionAction<HostServicesDelegate>) () -> {
  47                         if (getInstanceMeth == null) {
  48                             try {
  49                                 final String factoryClassName =
  50                                         "com.sun.deploy.uitoolkit.impl.fx.HostServicesFactory";
  51 
  52                                 Class factoryClass = Class.forName(factoryClassName,
  53                                         true,
  54                                         HostServicesDelegate.class.getClassLoader());
  55                                 getInstanceMeth = factoryClass.getMethod(
  56                                         "getInstance", Application.class);
  57                             } catch (Exception ex) {
  58                                 return null;
  59                             }
  60                         }
  61                         return (HostServicesDelegate)
  62                                 getInstanceMeth.invoke(null, app);
  63                     }
  64             );
  65         } catch (PrivilegedActionException pae) {
  66             System.err.println(pae.getException().toString());
  67             return null;
  68         }
  69         if (instance == null) {
  70             // in this case we are in standalone mode
  71             instance = StandaloneHostService.getInstance(app);
  72         }
  73         return instance;
  74     }
  75 
  76     protected HostServicesDelegate() {
  77     }
  78 
  79     public abstract String getCodeBase();
  80 
  81     public abstract String getDocumentBase();
  82 
  83     public abstract void showDocument(String uri);
  84 
  85     // StandaloneHostService implementation
  86     private static class StandaloneHostService extends HostServicesDelegate {
  87 
  88         private static HostServicesDelegate instance = null;
  89 
  90         private Class appClass = null;
  91 
  92         public static HostServicesDelegate getInstance(Application app) {
  93             synchronized (StandaloneHostService.class) {




  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.javafx.application;
  27 
  28 import java.awt.Desktop;
  29 import java.io.File;

  30 import java.net.URI;



  31 import javafx.application.Application;
  32 
  33 public abstract class HostServicesDelegate {
  34 


  35     public static HostServicesDelegate getInstance(final Application app) {
  36         return StandaloneHostService.getInstance(app);































  37     }
  38 
  39     protected HostServicesDelegate() {
  40     }
  41 
  42     public abstract String getCodeBase();
  43 
  44     public abstract String getDocumentBase();
  45 
  46     public abstract void showDocument(String uri);
  47 
  48     // StandaloneHostService implementation
  49     private static class StandaloneHostService extends HostServicesDelegate {
  50 
  51         private static HostServicesDelegate instance = null;
  52 
  53         private Class appClass = null;
  54 
  55         public static HostServicesDelegate getInstance(Application app) {
  56             synchronized (StandaloneHostService.class) {


< prev index next >