1 7 8 package org.jdesktop.swing; 9 10 import java.net.URL ; 11 12 import javax.jnlp.BasicService; 13 import javax.jnlp.ServiceManager; 14 import javax.jnlp.UnavailableServiceException; 15 16 20 class WebStartContext { 21 22 private static WebStartContext INSTANCE; 23 24 private WebStartContext() {} 25 26 public static WebStartContext getInstance() { 27 if (INSTANCE == null) { 28 INSTANCE = new WebStartContext(); 29 } 30 return INSTANCE; 31 } 32 33 37 BasicService getBasicService() { 38 BasicService bs = null; 39 try { 40 bs = (BasicService)ServiceManager.lookup("javax.jnlp.BasicService"); 41 } catch (UnavailableServiceException ex) { 42 System.err.println("WebStartContext - BasicServiceUnavaiable"); 44 } 45 return bs; 46 } 47 48 public void showDocument(URL url, String target) { 49 BasicService bs = getBasicService(); 50 if (bs != null) { 51 if (bs.showDocument(url) == false) { 52 System.err.println("WebStartContext - Error showing url: " + url); 54 } 55 } 56 } 57 58 65 public URL getDocumentBase() { 66 BasicService bs = getBasicService(); 67 if (bs != null) { 68 return bs.getCodeBase(); 69 } 70 return null; 71 } 72 } 73 | Popular Tags |